/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.mpower.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.mpower.model.Book;
import com.mpower.model.BookModel;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the Book service. Represents a row in the &quot;LIB_Book&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.mpower.model.BookModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link BookImpl}.
 * </p>
 *
 * <p>
 * Never modify or reference this class directly. All methods that expect a book model instance should use the {@link com.mpower.model.Book} interface instead.
 * </p>
 *
 * @author gavin
 * @see BookImpl
 * @see com.mpower.model.Book
 * @see com.mpower.model.BookModel
 * @generated
 */
public class BookModelImpl extends BaseModelImpl<Book> implements BookModel {
	public static final String TABLE_NAME = "LIB_Book";
	public static final Object[][] TABLE_COLUMNS = {
			{ "bookId", new Integer(Types.BIGINT) },
			{ "isbn", new Integer(Types.VARCHAR) },
			{ "title", new Integer(Types.VARCHAR) },
			{ "price", new Integer(Types.DOUBLE) },
			{ "totalcopies", new Integer(Types.INTEGER) },
			{ "addedDate", new Integer(Types.TIMESTAMP) },
			{ "modifiedDate", new Integer(Types.TIMESTAMP) }
		};
	public static final String TABLE_SQL_CREATE = "create table LIB_Book (bookId LONG not null primary key,isbn VARCHAR(75) null,title VARCHAR(75) null,price DOUBLE,totalcopies INTEGER,addedDate DATE null,modifiedDate DATE null)";
	public static final String TABLE_SQL_DROP = "drop table LIB_Book";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.mpower.model.Book"), true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.mpower.model.Book"), true);
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.mpower.model.Book"));

	public BookModelImpl() {
	}

	public long getPrimaryKey() {
		return _bookId;
	}

	public void setPrimaryKey(long pk) {
		setBookId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_bookId);
	}

	public long getBookId() {
		return _bookId;
	}

	public void setBookId(long bookId) {
		_bookId = bookId;
	}

	public String getIsbn() {
		if (_isbn == null) {
			return StringPool.BLANK;
		}
		else {
			return _isbn;
		}
	}

	public void setIsbn(String isbn) {
		_isbn = isbn;
	}

	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	public void setTitle(String title) {
		_title = title;
	}

	public double getPrice() {
		return _price;
	}

	public void setPrice(double price) {
		_price = price;
	}

	public int getTotalcopies() {
		return _totalcopies;
	}

	public void setTotalcopies(int totalcopies) {
		_totalcopies = totalcopies;
	}

	public Date getAddedDate() {
		return _addedDate;
	}

	public void setAddedDate(Date addedDate) {
		_addedDate = addedDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public Book toEscapedModel() {
		if (isEscapedModel()) {
			return (Book)this;
		}
		else {
			return (Book)Proxy.newProxyInstance(Book.class.getClassLoader(),
				new Class[] { Book.class }, new AutoEscapeBeanHandler(this));
		}
	}

	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					Book.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	public Object clone() {
		BookImpl clone = new BookImpl();

		clone.setBookId(getBookId());
		clone.setIsbn(getIsbn());
		clone.setTitle(getTitle());
		clone.setPrice(getPrice());
		clone.setTotalcopies(getTotalcopies());
		clone.setAddedDate(getAddedDate());
		clone.setModifiedDate(getModifiedDate());

		return clone;
	}

	public int compareTo(Book book) {
		long pk = book.getPrimaryKey();

		if (getPrimaryKey() < pk) {
			return -1;
		}
		else if (getPrimaryKey() > pk) {
			return 1;
		}
		else {
			return 0;
		}
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Book book = null;

		try {
			book = (Book)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = book.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(15);

		sb.append("{bookId=");
		sb.append(getBookId());
		sb.append(", isbn=");
		sb.append(getIsbn());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", price=");
		sb.append(getPrice());
		sb.append(", totalcopies=");
		sb.append(getTotalcopies());
		sb.append(", addedDate=");
		sb.append(getAddedDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(25);

		sb.append("<model><model-name>");
		sb.append("com.mpower.model.Book");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>bookId</column-name><column-value><![CDATA[");
		sb.append(getBookId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isbn</column-name><column-value><![CDATA[");
		sb.append(getIsbn());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>price</column-name><column-value><![CDATA[");
		sb.append(getPrice());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>totalcopies</column-name><column-value><![CDATA[");
		sb.append(getTotalcopies());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>addedDate</column-name><column-value><![CDATA[");
		sb.append(getAddedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _bookId;
	private String _isbn;
	private String _title;
	private double _price;
	private int _totalcopies;
	private Date _addedDate;
	private Date _modifiedDate;
	private transient ExpandoBridge _expandoBridge;
}